﻿using PMS.Core.Configuration.CommonEnumConfigs;
using PMS.Core.Utils;
using PMS.Data.Entities.NaviMenus;
using System;
using System.Collections.Generic;
using System.Text;

namespace PMS.Services.EntityServices.NaviMenus
{
    /// <summary>
    /// All Services for NaviMenu
    /// </summary>
    public interface INaviMenuService
    {
        #region NaviMenuGroups
        IList<NaviMenuGroup> GetNaviMenuGroupsAll(bool showHidden = false);

        NaviMenuGroup GetNaviMenuGroupById(int grpId);
        /// <summary>
        /// Get NaviMenuGroup By Predefined GroupName
        /// </summary>
        /// <param name="groupName"></param>
        /// <returns></returns>
        NaviMenuGroup GetNaviMenuGroupByName(MenuGroups groupName);
        #endregion

        #region NaviMenuTemplate
        /// <summary>
        /// Delete NaviMenu template
        /// </summary>
        /// <param name="layoutTemplate">NaviMenuLayout template</param>
        void DeleteNaviMenutLayoutTemplate(NaviMenuLayoutTemplate layoutTemplate);
        /// <summary>
        /// Gets all NaviMenu template
        /// </summary>
        /// <returns>NaviMenuLayout templates</returns>
        IList<NaviMenuLayoutTemplate> GetAllNaviMenuLayoutTemplates(bool showHidden = false);
        /// <summary>
        /// Gets a navimenu layout template
        /// </summary>
        /// <param name="layoutTemplateId">NaviMenuLayout template identifier</param>
        /// <returns>NaviMenuLayout template</returns>
        NaviMenuLayoutTemplate GetNaviMenuLayoutTemplateById(int layoutTemplateId);
        /// <summary>
        /// Inserts navimenu layout template
        /// </summary>
        /// <param name="layoutTemplate">NaviMenuLayout template</param>
        void InsertNaviMenuLayoutTemplate(NaviMenuLayoutTemplate layoutTemplate);
        /// <summary>
        /// Updates the navimenu layout template
        /// </summary>
        /// <param name="layoutTemplate">NaviMenuLayout template</param>
        void UpdateNaviMenuLayoutTemplate(NaviMenuLayoutTemplate layoutTemplate);
        #endregion

        #region NaviMenu-NaviMenuTemplate-Mapping
        /// <summary>
        /// Deletes a mapping
        /// </summary>
        /// <param name="mapping">NaviMenuNaviMenuTemplateMapping</param>
        void DeleteNaviMenuTemplateMapping(NaviMenuNaviMenuTemplateMapping mapping);
        /// <summary>
        /// Gets NaviMenuTemplates collection by NaviMenu
        /// </summary>
        /// <param name="naviMenuId">NaviMenu identifier</param>
        /// <returns>NaviMenuLayoutTemplate collection</returns>
        IList<NaviMenuLayoutTemplate> GetNaviMenuLayoutTemplatesByNaviMenuId(int naviMenuId);
        /// <summary>
        /// Inserts a NaviMenu-NaviMenuTemplate mapping
        /// </summary>
        /// <param name="mapping">>NaviMenuTemplayMapping</param>
        void InsertNaviMenuTemplayMapping(NaviMenuNaviMenuTemplateMapping mapping);
        #endregion

        #region NaviMenu
        /// <summary>
        /// Get a NaviMenu by identifier
        /// </summary>
        /// <param name="menuId"></param>
        /// <returns></returns>
        NaviMenu GetNaviMenuById(int menuId);

        /// <summary>
        /// Gets NaviMenus by identifier
        /// </summary>
        /// <param name="menuIds">NaviMenu identifiers</param>
        /// <returns>NaviMenu</returns>
        List<NaviMenu> GetNaviMenusByIds(int[] menuIds);
        /// <summary>
        /// Inserts NaviMenu
        /// </summary>
        /// <param name="menu">NaviMenu</param>
        void InsertNaviMenu(NaviMenu menu);

        /// <summary>
        /// Updates the NaviMenu
        /// </summary>
        /// <param name="menu">NaviMenu</param>
        void UpdateNaviMenu(NaviMenu menu);

        /// <summary>
        /// Delete NaviMenu
        /// </summary>
        /// <param name="menu">NaviMenu</param>
        void DeleteNaviMenu(NaviMenu menu);

        /// <summary>
        /// Delete a list of NaviMenu
        /// </summary>
        /// <param name="menus">NaviMenu</param>
        void DeleteNaviMenus(IList<NaviMenu> menus);
        /// <summary>
        /// Gets all NaviMenus Group by MenuGroup with all languages
        /// </summary>
        /// <param name="menuGrp">MenuGroups</param>
        /// <param name="storeId">Store identifier; 0 if you want to get all records</param>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <returns>NaviMenus</returns>
        IList<NaviMenu> GetAllNaviMenusByMenuGroup(MenuGroups menuGrp, int storeId = 0, bool showHidden = false);

        /// <summary>
        /// Gets all NaviMenus Group by MenuGroup
        /// </summary>
        /// <param name="menuGrp">MenuGroups</param>
        /// <param name="storeId">Store identifier; 0 if you want to get all records</param>
        /// <param name="pageIndex">Page index</param>
        /// <param name="pageSize">Page size</param>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <returns>NaviMenus</returns>
        IPagedList<NaviMenu> GetAllNaviMenusByMenuGroup(MenuGroups menuGrp, int storeId = 0,
            int pageIndex = 0, int pageSize = int.MaxValue, bool showHidden = false, string lanCode = "cn");

        /// <summary>
        /// Gets all NaviMenus Group by MenuGroupId
        /// </summary>
        /// <param name="menuGroupId">MenuGroups identified</param>
        /// <param name="storeId">Store identifier; 0 if you want to get all records</param>
        /// <param name="pageIndex">Page index</param>
        /// <param name="pageSize">Page size</param>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <returns>NaviMenus</returns>
        IPagedList<NaviMenu> GetAllNaviMenusByMenuGroup(int menuGroupId, int storeId = 0,
            int pageIndex = 0, int pageSize = int.MaxValue, bool showHidden = false, string lanCode = "cn");


        /// <summary>
        /// Sort navimenus for tree representation
        /// </summary>
        /// <param name="source">Source</param>
        /// <param name="parentId">Parent NaviMenu identifier</param>
        /// <param name="ignoreCategoriesWithoutExistingParent">A value indicating whether categories without parent category in provided category list (source) should be ignored</param>
        /// <returns>Sorted NaviMenus</returns>
        IList<NaviMenu> SortNaviMenusForTree(IList<NaviMenu> source, int parentId = 0,
            bool ignoreCategoriesWithoutExistingParent = false);

        /// <summary>
        /// Gets all NaviMenus filtered by parent NaviMenu identifier
        /// </summary>
        /// <param name="parentNaviMenuId">Parent category identifier</param>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <returns>NaviMenus</returns>
        IList<NaviMenu> GetAllNaviMenusByParentNaviMenuId(int parentNaviMenuId, bool showHidden = false);

        /// <summary>
        /// Gets child NaviMenus identifiers
        /// </summary>
        /// <param name="parentNaviMenuId">Parent NaviMenu identifier</param>
        /// <param name="storeId">Store identifier; 0 if you want to get all records</param>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <returns>NaviMenus identifiers</returns>
        IList<int> GetChildNaviMenuIds(int parentNaviMenuId, int storeId = 0, bool showHidden = false);
        /// <summary>
        /// Gets all NaviMenus displayed on the home page
        /// </summary>
        /// <param name="menuGroups">null to get all navimenus</param>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <returns>NaviMenus</returns>
        IList<NaviMenu> GetAllNaviMenusDisplayedOnHomepage(MenuGroups? menuGroups = null,  bool showHidden = false);

        /// <summary>
        /// Get formatted NaviMenu breadcrumb 
        /// Note: ACL and store mapping is ignored
        /// </summary>
        /// <param name="menu">NaviMenu</param>
        /// <param name="allMenus">All NaviMenu</param>
        /// <param name="separator">Separator</param>
        /// <returns>Formatted breadcrumb</returns>
        string GetFormattedBreadCrumb(NaviMenu menu, IList<NaviMenu> allMenus = null,
            string separator = ">>");

        /// <summary>
        /// Get NaviMenu breadcrumb 
        /// </summary>
        /// <param name="menu">NaviMenu</param>
        /// <param name="allMenus">All NaviMenu</param>
        /// <param name="showHidden">A value indicating whether to load hidden records</param>
        /// <returns>NaviMenu breadcrumb </returns>
        IList<NaviMenu> GetNaviMenuBreadCrumb(NaviMenu menu, IList<NaviMenu> allMenus = null, bool showHidden = false);
        #endregion
    }
}
